/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.ucsur.tp.colegio.tempdata;

import edu.ucsur.tp.colegio.beans.GradosBean;
import edu.ucsur.tp.colegio.beans.SedeBean;
import edu.ucsur.tp.colegio.beans.TurnosBean;
import edu.ucsur.tp.colegio.database.DBConnection;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

public class MySqlGradoDAOImpl implements GradoDAO {
    
    public GradosBean getGradoDAO(String txtCodigoGrado) {
    String sql = "SELECT * FROM grado WHERE txtCodigoGrado = ?";
    try {
      //1. Obtener la conexi�n
      Connection conn = DBConnection.getConnection();
      //2. Obtenemos la sentencia Java (PreparedStatement)
      PreparedStatement pstmt = conn.prepareStatement(sql);
      //-- 2.1. Setear los par�metros din�micos
      pstmt.setString(1, txtCodigoGrado);
      //3. Ejecutar la sentencia (se recupera en un cursor)
      ResultSet rs = pstmt.executeQuery();
      //4. Recorriendo el cursor
      if (rs.next()) {
        GradosBean grado = new GradosBean();
        grado.setTxtCodigoGrado(rs.getString("codigo_usuario"));
        grado.setTxtAulaGrado(rs.getString("aula"));
        grado.setTxtGrado(rs.getString("grado"));
        grado.setTxtSeccionGrado(rs.getString("seccion"));
        return grado;
      }
      //5. Cerrando los recursos JDBC
      rs.close();
      pstmt.close();
      conn.close();
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    return null;
  }

    @Override
    public GradosBean getGrado(String txtcodigoGrado) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public List<GradosBean> getListaGrados() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void insertar(GradosBean grado) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void eliminar(String txtCodigoGrado) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

  
}
